package object;

/**
 * 抽象类和抽象方法
 * @author galen
 */
abstract class Shape {
    public int width;
    public int height;

    public Shape(int width, int height) {
        this.width = width;
        this.height = height;
    }

    /**
     * 定义抽象方法，计算面积
     * @return
     */
    public abstract double area();

}

/**
 * 继承抽象类
 * @author galen
 */
public class Square extends Shape {
    public Square(int width, int height) {
        super(width, height);
    }

    @Override
    public double area() {
        return width*height;
    }

    public static void main(String[] args) {
        Square square = new Square(5, 4);

        System.out.println("正方形的面积为：" + square.area());
    }
    
}